using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Data.SqlServerCe;
using System.IO;
using System.Reflection;
using System.Text;
using System.Net;
using System.Windows.Forms;

namespace Kiss.Mobile
{
    /// <summary>
	/// This singleton class holds the common application values.
	/// </summary>
	sealed class Common
	{
        private readonly string localDatabase = "Northwind.sdf";

        // Singleton instance variable (Values)
		public static readonly Common Values = new Common();

        /// <summary>
        /// Private constructor to prevent external instance creation.
        /// </summary>
        private Common() { }

        private SqlCeConnection databaseConnection;
	    public SqlCeConnection DatabaseConnection
	    {
		    get
            {
                if(databaseConnection == null)
                {
                    string connectionString = "Data Source=" + Path.Combine(Path.GetDirectoryName(
                        Assembly.GetExecutingAssembly().GetName().CodeBase), localDatabase);
                    databaseConnection = new SqlCeConnection(connectionString);
                    databaseConnection.Open();
                }
                return databaseConnection;
            }
		    set { databaseConnection = value; }
	    }
    }
}
